package org.blogwu.learn.multithread.chapter3.demo10;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FixedThreadDemoV2 extends Thread {
    public FixedThreadDemoV2(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(getName() + Thread.currentThread().getId() + " start");
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        FixedThreadDemoV2 fixedThreadDemo = new FixedThreadDemoV2("测试");
        ExecutorService e = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 2000; i++) {
            e.submit(fixedThreadDemo);
        }
        Thread.sleep(10000);
        System.out.println("hello");
    }
}
